<template>
  <div class="head-container">
    <div class="crud-opts">
      <el-button
        v-permission="['SYS_ADMIN','COMMON_ADMIN','WAREHOUSE_ALL','WAREHOUSE_CREATE','WAREHOUSE_CHANGE']"
        class="filter-item"
        size="mini"
        type="primary"
        icon="el-icon-plus"
        @click="toAdd">新增</el-button>
      <el-button
        v-permission="['SYS_ADMIN','COMMON_ADMIN','WAREHOUSE_ALL','WAREHOUSE_CREATE','WAREHOUSE_CHANGE']"
        class="filter-item"
        size="mini"
        type="primary"
        icon="el-icon-copy-document"
        @click="toCopy">复制</el-button>
      <el-button
        v-permission="['SYS_ADMIN','COMMON_ADMIN','WAREHOUSE_ALL','WAREHOUSE_DELETE']"
        v-loading="sup_this.deleteLoading"
        class="filter-item"
        size="mini"
        type="danger"
        icon="el-icon-delete"
        @click="doMultiDelete">删除</el-button>
      <el-button
        class="filter-item"
        size="mini"
        type="success"
        icon="el-icon-printer"
        @click="doPrintBarcode">打印条码</el-button>
    </div>
  </div>
</template>

<script>
import { deleteUrl } from '@/api/base/storageLocation'
export default {
  components: { },
  props: {
    paramBean: {
      type: Object,
      required: true
    },
    sup_this: {
      type: Object,
      required: true
    }
  },
  methods: {
    refreshClick() {
      this.sup_this.init()
    },
    searchClick() {
      this.sup_this.toggleSearch()
    },
    beforeCreate() {
    },
    doMultiDelete() {
      const _this = this.sup_this
      _this.doMultiDelete(deleteUrl(), this)
    },
    toAdd() {
      const _this = this.sup_this
      const busMainData = { warehouseId: _this.warehouseData.id }
      const _thisform = _this.$refs.form
      _thisform.initDataOfBefore()
      _thisform.addData(busMainData)
    },
    toCopy() {
      const _this = this.sup_this
      const selectMainId = _this.getSelectMainId()
      if (!selectMainId) {
        return
      }
      const _thisForm = _this.$refs.form
      _thisForm.initDataOfBefore()
      _thisForm.copyData(selectMainId)
    },
    doPrintBarcode() {
      const barcodeList = []
      const _this = this.sup_this
      _this.selectedGridRows.forEach(row => {
        barcodeList.push({ barcode: row.id, barcodeName: row.slName, barcodeLabel: row.thirdCode })
      })
      const printBarcode = _this.$refs.printBarcodePage
      printBarcode.loadPrintPage(barcodeList)
    }
  }
}
</script>
